package sensor;

import lejos.nxt.*;
import lejos.nxt.comm.RConsole;
import lejos.util.Delay;


public class UltraSonicEj {
	
		  public static void main(String[] args) throws Exception {
		    UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S1);
		    
		    RConsole.openBluetooth(0);
		    RConsole.println("Start for loop ");
		    LCD.drawString(sonic.getVendorID(), 0, 0);
		    LCD.drawString(sonic.getProductID(), 0, 1);
		    LCD.drawString(sonic.getVersion(), 0, 2);
		    int dist=0;
		    while (!Button.ESCAPE.isDown()) {
		    	dist=sonic.getDistance();
		    	RConsole.println(Integer.toString(dist));
			      LCD.drawInt(dist, 0, 3);
			      Delay.msDelay(2000);
			      LCD.clear(3);
		    }
		  }
		

}
